package com.vgemv.jsutilitysdk.String;

import org.intellij.lang.annotations.RegExp;

public class JsStringValidator {
    static public boolean isValidUrlAddress(String urlString) {
        //^http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?
        if(!urlString.matches("^http(s)?://.*")) {
            return false;
        }
//        if(!urlString.matches("^http(s)?://([\\w-]+\\.)+[\\w-]+(/[\\w- ./?%&=]*)?")) {
//            return false;
//        }
        return true;
    }
    static public boolean isValidRtmpAddress(String urlString) {
        //rtmp://169.vgemv.com:8800/live/14839?vhost=vlive&token=
        //^rtmp://.* 仅仅是rtmp://开头.

        //开头
        if(!urlString.matches("^rtmp://.*")) {
            return false;
        }
//        if(!urlString.matches("^rtmp://([\\w-]+\\.)+[\\w-]+(/[\\w- ./?%&=]*)?")) {
//            return false;
//        }
        if(urlString.length() < 10) {
            return false;
        }
        return true;
    }

    static public boolean isValidHlsAddress(String urlString) {
        //https://169.vgemv.com:48801/live/14839/index.m3u8?vhost=vlive&token=
        if(!isValidUrlAddress(urlString)) {
            return false;
        }
        if(urlString.length() < 10) {
            return false;
        }
        if(!urlString.contains(".m3u8")) {
            return false;
        }
        return true;
    }
}
